package leetcode.Two_hundred_to_Three_hundred;

/**
 * 222. 完全二叉树的节点个数
 */
public class Test222 {

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    int count = 0;
    public int countNodes(TreeNode root) {
        if (root == null) {
            return 0;
        }
        count++;
        countNodes(root.left);
        countNodes(root.right);
        return count;
    }
}
